<?
//
//  copyrigth Andy Malahovsky 05-05-2002
//

class RBNS_pages_admin extends RBNS_base{ 
  
var $name='';
var $unset=false;    


function getHAIarray(){
 $query="select * from pages";
 $result=base_query($query);
 while($det=base_fetch_assoc($result))
 {
  $name=$det[name];
  $HAI[$name]=$det;	
 };
 return $HAI;
}	


function getPageDetailFromURL($url='',$pageTemplateVersion=''){

 if(empty($url)){
  	$url=$_SERVER['REQUEST_URI'];
 };
 
 $el=explode('/',$url);
 for($i=1;$i<count($el);$i++){ 
 	
 	if($this->unset) unset($el[$i]);
 	$ell=explode('?',$el[$i]);
 	if(is_array($ell)&&($el[$i]!=$ell[0])){
 		$el[$i]=$ell[0];	
 		$unset=true;
 	}	
 	
 };	
 $page=$wh='';
 for($i=0;$i<count($el);$i++){ 
 	if(empty($el[$i])) continue;
 	$page.=($page)?"/".$el[$i]:$el[$i];
 	$wh.=($wh)?" OR name='$page' ":" name='$page' ";	
 }
 
 $query="select * from pages where $wh order by name DESC";
 $result=base_query($query);
 if($det=base_fetch_assoc($result))
 {
  	if($pageTemplateVersion){
        $tn=substr($det['template'],0,$pos=strrpos($det['template'],'.')).".".$pageTemplateVersion.substr($det['template'],$pos);
        if(is_file($_SERVER['DOCUMENT_ROOT'].$tn)) $det['template']=$tn;
    }
  	return $det;
 };
 return false;
 
}



 




};//class RBNS_pages_admin
?>